using System;

namespace Terra.Core.Configuration.Options
{
    /// <summary>
    /// 应用程序基础配置
    /// </summary>
    public class AppSettings
    {
        /// <summary>
        /// 应用程序名称
        /// </summary>
        public string AppName { get; set; } = "Terra";

        /// <summary>
        /// 应用程序版本
        /// </summary>
        public string Version { get; set; } = "1.0.0";

        /// <summary>
        /// API前缀
        /// </summary>
        public string ApiPrefix { get; set; } = "api/v1";

        /// <summary>
        /// 是否启用Swagger
        /// </summary>
        public bool EnableSwagger { get; set; } = true;

        /// <summary>
        /// 跨域配置
        /// </summary>
        public CorsSettings Cors { get; set; } = new();

        /// <summary>
        /// 缓存配置
        /// </summary>
        public CacheSettings Cache { get; set; } = new();
    }

    /// <summary>
    /// 跨域配置
    /// </summary>
    public class CorsSettings
    {
        /// <summary>
        /// 是否启用跨域
        /// </summary>
        public bool EnableCors { get; set; } = true;

        /// <summary>
        /// 允许的来源
        /// </summary>
        public string[] AllowedOrigins { get; set; } = Array.Empty<string>();

        /// <summary>
        /// 允许的HTTP方法
        /// </summary>
        public string[] AllowedMethods { get; set; } = new[] { "GET", "POST", "PUT", "DELETE", "OPTIONS" };

        /// <summary>
        /// 允许的请求头
        /// </summary>
        public string[] AllowedHeaders { get; set; } = new[] { "*" };
    }

    /// <summary>
    /// 缓存配置
    /// </summary>
    public class CacheSettings
    {
        /// <summary>
        /// 缓存提供程序(Redis/Memory)
        /// </summary>
        public string Provider { get; set; } = "Memory";

        /// <summary>
        /// Redis连接字符串
        /// </summary>
        public string RedisConnection { get; set; } = "localhost:6379";

        /// <summary>
        /// 默认过期时间(分钟)
        /// </summary>
        public int DefaultExpirationMinutes { get; set; } = 30;
    }
}